/**
 * 生成双色球号码
 *
 * @author caojianyu
 * @date 2020/01/15
 * @mail jieni_cao@foxmail.com
 */
public class TwoColorBall {

    public void randomGeneration(String color, int quantity, int scope) {
        //返回的球的号码
        int[] ballNumber = new int[quantity];
        for (int i = 0; i < ballNumber.length; i++) {
            int number = (int) (Math.random() * scope + 1);
            for (int j = 0; j < i; j++) {
                if (number == ballNumber[j]) {
                    number = (int) (Math.random() * scope + 1);
                    j = 0;
                }
            }
            ballNumber[i] = number;
        }
        System.out.print(color + "开奖号码为：");
        for (int i = 0; i < ballNumber.length; i++) {
            System.out.print("\t" + ballNumber[i]);
        }
    }
}


